<template>
   <div>
       <el-button type="primary" @click="handleAdd">添加</el-button>
    <el-table
     :data="commodityData"
     border
     style="width: 100%">
     </el-table-column>
    <el-table-column
       prop="commodity_id"
        align="center"
       label="活动id"
       width="0">
     </el-table-column>
     <el-table-column
       prop="money_up"
       label="投资金额上限"
         align="center"
       width="120">
     </el-table-column>
     <el-table-column
       prop="money_down"
       label="投资金额下限"
         align="center"
       width="80">
     </el-table-column>
     <el-table-column
       prop="day_income"
         align="center"
       label="日利润"
       width="80">
     </el-table-column>
     <el-table-column
       prop="month_income"
         align="center"
       label="月利润"
       width="80">
     </el-table-column>
     <el-table-column
       prop="sell_start_time"
         align="center"
       label="合约开始时间"
       width="80">
     </el-table-column>
     <el-table-column
       prop="sell_end_time"
         align="center"
       label="合约结束时间"
       width="80">
     </el-table-column>
     <el-table-column
       prop="period"
         align="center"
       label="周期"
       width="80">
     </el-table-column>
     <el-table-column
       prop="create_time"
         align="center"
       label="创建时间"
       width="80">
     </el-table-column>
     <el-table-column
       prop="zhitui_income"
         align="center"
       label="直推奖励比例"
       width="80">
     </el-table-column>
     <el-table-column
       fixed="right"
       align="center"
       label="操作"
       width="150">
       <template slot-scope="scope">
         <el-button @click="handleBj(scope.row)" type="text" size="small">编辑</el-button>
       </template>
     </el-table-column>
   </el-table>
    <div class="pagination">
        <el-pagination background
    		@current-change="handleCurrentChange"
    		layout="prev, pager, next"
    		:total="pages"
    		:page-size="pageSize">
        </el-pagination>
    </div>

   </div>
</template>

<script>

    export default {
          data() {
              return{
                  //翻页
                page:1,
                pageSize:10,
                pages:1,
                //投资列表
                commodityData:[]
              }
          },
            methods:{
                getData(){
                      let params = {
                          page:this.page,
                          page_size:this.pageSize,

                      }

                  this.$post_('trade/commodity/list-info',params,(res) => {
                      console.log(res)
                      if(res.code ==0){
                          this.commodityData = res.data
                          this.pages = Number(res.extend.pages);
                      }
                  })
                },
                handleBj(row){
                    console.log(row)
                     this.$router.push({path:'/page/invest/invest_edit',query:{commodity_id:row.commodity_id} });
                },
                handleCurrentChange(val){
                    this.page = val
                    this.getData()
                },
                handleAdd(){
                     this.$router.push({path:'/page/invest/invest_add'})
                }
          },
          created(){
              this.getData()
          }
    }
</script>

<style>
</style>
